<%@ page import="com.tlb.ejb.*,com.tlb.dto.*,com.tlb.web.*,java.util.*" %>

<%

boolean nsfw = "true".equalsIgnoreCase(request.getParameter("nsfw"));
int monikerId = Integer.parseInt(request.getParameter("monikerId"));
Poster p = new AuthManager(request, response).hardAuthenticatePoster(monikerId);



if(request.getParameter("title") == null || request.getParameter("title").length() < 1 || request.getParameter("title").trim().equals("")) {
    out.println("Title cannot be empty");
    out.flush();
    return;
}

if(request.getParameter("title").length() > 63) {
    out.println("Title too long");
    out.flush();
    return;
}



PostView pv = new PostView();
pv.setTitle(request.getParameter("title"));
pv.setContent(request.getParameter("cont"));
pv.setMonikerId(monikerId);
pv.setNsfw(nsfw);
int ntId = new ThreadDAO().addThread(pv);





if(ntId > 0) {
    response.setStatus(response.SC_MOVED_TEMPORARILY);
//response.setHeader("Location", "http://www.biglawboard.com/blb/viewThread.jsp?threadId=" + ntId);
    response.setHeader("Location", "http://" + Util.getUtil().getServerRoot(request) + "/blb/viewThread.jsp?threadId=" + ntId + "&x=1");
    
} else {
    System.out.println("Bad new thread Id, sending back to index.");
    request.getRequestDispatcher("/index.jsp").forward(request, response);
}
%>
